package com.xszx.server.service;

import com.xszx.server.dto.Page;
import com.xszx.server.entity.Member;
import com.xszx.server.entity.MemberCourse;
import com.xszx.server.mapper.MemberCourseMapper;
import com.xszx.server.util.UuidUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Date;

@Service
public class MemberCourseService {
    @Resource
    private MemberCourseMapper memberCourseMapper;



    /**
     * 报名
     * @param memberCourse
     * @return
     */
    public MemberCourse enroll(MemberCourse memberCourse){
            memberCourse.setId(UuidUtil.getShortUuid());
            memberCourse.setAt(new Date());
            memberCourseMapper.insert(memberCourse);
            return memberCourse;
    }

    /**
     * 物理删除会员课程报名
     * @param id
     * @return
     */
    public int del(String id){
        return memberCourseMapper.deleteByPrimaryKey(id);
    }
     /**
     * 获取单个会员课程报名
     * @return
     */
    public MemberCourse getMemberCourse(String id){
        return memberCourseMapper.selectByPrimaryKey(id);
    }

    /**
     * 获取报名信息
     * @return
     */
    public MemberCourse getEnroll(MemberCourse memberCourse){
        return memberCourseMapper.selectMember(memberCourse);
    }
}
